set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide Pascal Source"
else set the name of me to "Show Pascal Source"
end mouseUp
-- part contents for background part 16
----- text -----
PASSWORD XFCN version 1.0.1
Kevin Calhoun
Password behaves in almost the same way as the HyperTalk command "ask password". It differs in that it is capable of distinguishing between upper- and lower-case characters and in that it displays bullets in the ask dialog box instead of the actual password. This is useful if you want to hide what you type from your little brother, your boss, or your archrival in software development.
Password returns a number which it derives from the password that's entered. This number can be stored in a field to be compared with the result of a subsequent call to Password if, for example, you want the user to be able to protect data contained in the stack. Given a ne'er-do-well with access to enough CPU time or a whiz at 68000 opcodes with a good disassembler, it's not difficult to imagine that the encryption scheme that Password employs can be broken. Use it only if your little brother, boss, or archrival in software development has better things to do than to hack your stack.
Note that the number returned by Password for a particular string is not the same as the number returned for that string by the HyperTalk command "ask password".
INVOKING PASSWORD
get Password(<"prompt">,<caseSensitive>)
result: a number
If parameter 1 is present, it becomes the prompt string that appears in the same place as a question that's passed to the HyperTalk command ask. If parameter 1 is not present, Password uses the prompt, "Please enter your password:".
If caseSensitive is TRUE, then Password distinguishes between upper- and lower-case characters when encrypting the password. If it is absent, or it is anything other than TRUE, Password does not distinguish between upper- and lower-case characters.
If an error occurs, Password returns a string, the first word of which will be "Error". If the user clicks the Cancel button, Password returns "Cancel". If the user types nothing before clicking the OK button, Password returns 0.
My thanks to Jim Matthews for the filter function that handles the bullets.
Revision history:
15 March 1989 -- first release.
11 June 1989 -- Changed the way the prompt message is set for compatibility with SuperCard. (No longer use ParamText. Use SetIText instead.)
-- part contents for card part 2
----- text -----
UNIT PasswordUnit;
{ This source compatible with MPW Pascal 3.0 }
{ Password XFCN ©1989 by the Trustees of Dartmouth College }
{ Written by Kevin Calhoun }
(*
Pascal Password.p
Link -m ENTRYPOINT Γêé
-o "YourFile" Γêé
-rt XFCN=17958 Γêé
-sn Main=Password Γêé
Password.p.o Γêé
"{Libraries}"interface.o Γêé
"{PLibraries}"Paslib.o Γêé
"{Libraries}"HyperXLib.o
*)
{$R-}
INTERFACE
USES
Types,
Memory,
Resources,
Dialogs,
ToolUtils,
OSUtils,
HyperXCmd;
PROCEDURE Entrypoint (paramPtr : XCmdPtr);
IMPLEMENTATION
PROCEDURE DoPassword(paramPtr: XCMDPtr); FORWARD;
PROCEDURE Entrypoint(paramPtr: XCMDPtr);
BEGIN
DoPassword(paramPtr);
END;
FUNCTION GetScreenBitsBounds: Rect;
{ get screenbits.bounds from the QuickDraw globals }
TYPE
LongwordPtr = ^LONGINT;
BitMapPtr = ^BitMap;
CONST
screenBitsOffset = -122;
CurrentA5 = $904;
VAR
screenBitsPtr : BitMapPtr;
myLongwordPtr : LongwordPtr;
BEGIN
myLongwordPtr := LongwordPtr(CurrentA5);
{ myLongwordPtr now points to the pointer to the first QD global }
myLongwordPtr := LongwordPtr(myLongwordPtr^);
{ myLongwordPtr now points to the first QD global }